﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using HengTong.Model.Db.Hr;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Attributes;

namespace HengTong.Model.Db.Hr.Bill;

/// <summary>
/// 调休申请
/// 员工发起调休申请, 读取加班申请表中该员工3个月内仍有剩余可调休小时数的加班记录, 选择使用部分或全部加班小时数进行调休
/// </summary>
[Display(Name = "调休申请", Description = "员工调休申请表单", GroupName = "日常业务表单")]
public class SysDailyCompOffRequestBill : BaseBill
{
    [Required]
    [Display(Name = "员工ID", Description = "关联员工主键", GroupName = "员工信息")]
    public Guid? PersonId { get; set; }

    [Display(Name = "员工", Description = "关联的员工实体", GroupName = "员工信息")]
    public SysPerson Person { get; set; }

    [Required, StringLength(128)]
    [Display(Name = "员工工号", Description = "员工工号", GroupName = "调休申请信息")]
    public string StaffNo { get; set; }

    [Required, StringLength(128)]
    [Display(Name = "员工姓名", Description = "员工姓名", GroupName = "调休申请信息")]
    public string Name { get; set; }

    [Required]
    [Display(Name = "开始时间", Description = "开始时间", GroupName = "调休申请信息")]
    public DateTime? StartTime { get; set; }

    [Required]
    [Display(Name = "结束时间", Description = "结束时间", GroupName = "调休申请信息")]
    public DateTime? EndTime { get; set; }

    [Required, Column(TypeName = "decimal(8,2)")]
    [Display(Name = "天数", Description = "天数", GroupName = "调休申请信息")]
    public decimal? Days { get; set; }

    [Required, StringLength(256)]
    [Display(Name = "事由", Description = "事由", GroupName = "调休申请信息")]
    public string Reason { get; set; }

    [Required]
    [Display(Name = "调休类型", Description = "正常调休/等时调休", GroupName = "调休申请信息")]
    public CompOffType? CompOffType { get; set; }

    [Column(TypeName = "decimal(8,2)")]
    [Display(Name = "调休时长(小时)", Description = "等时调休使用的小时数", GroupName = "调休申请信息")]
    public decimal? CompOffHours { get; set; }
    
    public List<SysCompOffOvertimeLink> CompOffOvertimeLinks { get; set; }
}

//调休和加班关联表
[MiddleTable]
public class SysCompOffOvertimeLink : TopBasePoco
{
    [Required]
    public Guid CompOffRequestBillId { get; set; }
    public SysDailyCompOffRequestBill CompOffRequestBill { get; set; }

    [Required]
    public Guid OvertimeRequestBillId { get; set; }
    public SysDailyOvertimeRequestBill OvertimeRequestBill { get; set; }

    [Required, Column(TypeName = "decimal(8,2)")]
    public decimal HoursUsed { get; set; } // 使用的加班小时数
}